def read1(input_file1, input_file2):
    sentence = []
    target = []
    position = []
    # palority = []
    attention = []

    lines = open(input_file1).readlines()
    for i in range(0, len(lines), 3):
        target.append(lines[i])
        sentence.append(lines[i + 1])
        position.append(lines[i + 2])

    lines = open(input_file2).readlines()
    for i in range(len(lines)):
        # palority.append(lines[i])
        attention.append(lines[i])

    return target, sentence, position, attention


def write(input_file1, input_file2, output_file_1):
    target, sentence, position, attention = read1(input_file1, input_file2)
    fp = open(output_file_1, 'w')
    for seg in range(len(sentence)):
        fp.write(target[seg])
        fp.write(sentence[seg])
        fp.write(position[seg])
        fp.write(attention[seg])


if __name__ == "__main__":
    file1 = 'data/16res/test.txt'
    # file2 = 'data/14lap/palority_test_1.txt'
    file2 = 'data/16res/16res_test_att.txt'
    file3 = 'data/16res/test_2.txt'

    write(file1, file2, file3)
